<div class="aside">
    <div class="profile">
        <img class="avatar" src="../static/uploads/avatar.jpg">
        <h3 class="name">布头儿</h3>
    </div>
    <ul class="nav">
        <li class="active">
        <a href="index.php"><i class="fa fa-dashboard"></i>仪表盘</a>
        </li>
        <li>
            <?php 
                //声明一个变量 假设此处的列表$isOpen = true时为展开,false为合起
                $postArr = ['posts','post-add','categories'];
                $isOpen=in_array($currentPage,$postArr);
            ?>
            <a href="#menu-posts" class="<?php echo $isOpen ? '':'collapsed' ?>" 
            <?php echo $isOpen ? 'aria-expanded="true"' :'' ?> 
            data-toggle="collapse">
                <i class="fa fa-thumb-tack"></i>文章<i class="fa fa-angle-right"></i>
            </a>
            <ul id="menu-posts" class="collapse <?php echo $isOpen ? 'in':'' ?> " <?php echo $isOpen ? 'aria-expanded="true"' :'' ?> >
                <li><a href="posts.php">所有文章</a></li>
                <li><a href="post-add.php">写文章</a></li>
                <li><a href="categories.php">分类目录</a></li>
            </ul>
        </li>
        <li>
        <a href="comments.php"><i class="fa fa-comments"></i>评论</a>
        </li>
        <li>
        <a href="users.php"><i class="fa fa-users"></i>用户</a>
        </li>
        <li>
            <?php 
                //声明一个变量 假设此处的列表$isOpen = true时为展开,false为合起
                $postArr1 = ['nav-menus','slides','settings'];
                $isOpen1 = in_array($currentPage1,$postArr1);
            ?>
            <a href="#menu-settings" class="<?php echo $isOpen1 ? '':'collapsed' ?>" 
            <?php echo $isOpen1 ? 'aria-expanded="true"' :'' ?> 
            data-toggle="collapse">
                <i class="fa fa-cogs"></i>设置<i class="fa fa-angle-right"></i>
            </a>
            <ul id="menu-settings" class="collapse <?php echo $isOpen1 ? 'in':'' ?> " <?php echo $isOpen1 ? 'aria-expanded="true"' :'' ?> >
                <li><a href="nav-menus.php">导航菜单</a></li>
                <li><a href="slides.php">图片轮播</a></li>
                <li><a href="settings.php">网站设置</a></li>
            </ul>
        </li>
    </ul>
</div>
<script src="../static/assets/vendors/jquery/jquery.min.js"></script>
<script>
    $(function(){
        //获取用户名和头像
        $.ajax({
            type:"post",
            url:"api/_getUserVavatar.php",
            success:function(res){
                //判断是不是有这个用户
                if(res.code == 1){
                    $('.avatar').attr("src",res.avatar);
                    $('.name').text(res.nickname);
                }
                // console.log(res);
            }
        });
    });
</script>